package com.luoran.bartalks.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.luoran.bartalks.dao.IBtPlanBizDao;
import com.luoran.bartalks.entity.biz.BtPlanBiz;
import com.luoran.bartalks.service.IBtPlanBizService;

@Service
public class BtPlanBizService implements IBtPlanBizService {

	@Autowired
	private IBtPlanBizDao planBizDao;

	// 根据计划途径点关系表的id,计划id.项目id.查询已装记录条数
	@Override
	public int getInedItemCount(String planPositionId, String planId, String projectId) {
		return planBizDao.getInedItemCount(planPositionId, planId, projectId);
	}

	// 根据计划途径点关系表的iD,计划id,项目id.查询已卸记录条数.
	@Override
	public int getOutedItemCount(String planPositionId, String planId, String projectId) {
		return planBizDao.getOutedItemCount(planPositionId, planId, projectId);
	}

	// 查询在该项目的容器中是否在应卸中
	@Override
	public BtPlanBiz findPlanBizByPlanpositionIdAndContainerId(String planId, String materielId, String containerId,
			String planPositionId) {
		return planBizDao.findPlanBizByPlanpositionIdAndContainerId(planId, materielId, containerId, planPositionId);
	}

	// 新增装卸货信息
	@Override
	public void addPlanBiz(BtPlanBiz btPlanBiz) {
		planBizDao.insertTemplate(btPlanBiz);
	}

	// 根据计划途径点关系表的id,计划id.所属容器id.查询该容器已装物料条数
	@Override
	public int getInedItemCountByContainer(String planPositionId, String planId, String containerId) {
		return planBizDao.getInedItemCountByContainer(planPositionId, planId, containerId);
	}

	// 根据计划途径点关系表的id,计划id.所属容器id.查询该容器已卸物料条数
	@Override
	public int getOutedItemCountByContainer(String planPositionId, String planId, String containerId) {
		return planBizDao.getOutedItemCountByContainer(planPositionId, planId, containerId);
	}

	// 根据计划途径点关系表的id,计划id.所属容器id.查询该容器已装物料信息
	@Override
	public List<BtPlanBiz> getInedItemInfoCountByContainer(String planPositionId, String planId, String containerId) {
		return planBizDao.getInedItemInfoCountByContainer(planPositionId, planId, containerId);
	}

	// 根据计划途径点关系表的id,计划id.所属容器id.查询该容器已卸物料信息
	@Override
	public List<BtPlanBiz> getOutedItemInfoCountByContainer(String planPositionId, String planId, String containerId) {
		return planBizDao.getOutedItemInfoCountByContainer(planPositionId, planId, containerId);
	}

	// 根据计划id与地点id查询应有的容器
	@Override
	public List<BtPlanBiz> findContainersByPlanPositionIdAndPlanId(String planPositionId, String planId) {
		return planBizDao.findContainersByPlanPositionIdAndPlanId(planPositionId, planId);
	}

	// 通过对象删除
	@Override
	@Transactional()
	public int deleteOutedItemInfoCountByContainer(String id) {
		return planBizDao.deleteById(id);
	}

	// 查询是否是该计划的物料
	@Override
	public BtPlanBiz findmaterielByPlanpositionIdAndplanId(String planId, String materielId, String planPositionId) {
		return planBizDao.findmaterielByPlanpositionIdAndplanId(planId, materielId, planPositionId);
	}

	//获取同一容器下的物料记录.
	@Override
	public List<BtPlanBiz> getContainerExtraInfo(String projectId, String planId, String planPositionId,
			String containerId) {
		
		return planBizDao.getContainerExtraInfo(projectId,planId,planPositionId,containerId);
	}

	//根据箱单物料id,查询当前点该物料是否存在装货记录
	@Override
	public BtPlanBiz getItemByPackingListMaterielIdAndPlanPositionId(String packingListMaterielId,
			String planPositionId,int bizType) {
		return planBizDao.getItemByPackingListMaterielIdAndPlanPositionId(packingListMaterielId,planPositionId,bizType);
	}

	@Override
	public String getIdByPackingListMaterielId(String packingListMaterielId, String planPositionId, int bizType) {
		return planBizDao.getIdByPackingListMaterielId(packingListMaterielId, planPositionId, bizType);
	}

}
